using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input.Touch;

namespace WTCOTH
{
    class button
    {
        SpriteBatch batch;
        Texture2D texture;
        int width, height, x, y;
        Color colour, colour2;

        public button(SpriteBatch spriteBatch, Texture2D texture, Color colour, int width, int height, int x, int y)
        {
            this.batch = spriteBatch;
            this.texture = texture;
            this.width = width;
            this.height = height;
            this.x = x;
            this.y = y;
            this.colour = colour;
            this.colour2 = colour;
            this.colour2.A = 128;
        }

        public void draw()
        {
            this.batch.Draw(texture, new Rectangle(this.x, this.y, this.width, this.height), colour);
        }

        public bool is_pressed()
        {

            TouchCollection touches = TouchPanel.GetState();
            if (touches.Count > 0)
            {
                
                foreach( TouchLocation location in touches )
                {
                    if (location.Position.X > this.x &&
                        location.Position.X < (this.x + this.width) &&
                        location.Position.Y > this.y &&
                        location.Position.Y < (this.y + this.height))
                    {
                        return true;
                    }
                }

            }
            return false;
        }

    }
}
